package com.freesky.web.portal.controller;

import com.freesky.common.pojo.Result;
import com.freesky.common.utils.reponse.JSONResponse;
import com.freesky.common.vo.VOAddress;
import com.freesky.web.portal.reomte.AddressRemote;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Freesky
 */
@RestController
@Api(description = "收货地址")
public class AddressController {

    @Autowired
    private AddressRemote addressRemote;

    @PostMapping(value = "/member/address/list")
    @ApiOperation(value = "获得所有收货地址")
    public JSONResponse addressList(@RequestBody VOAddress address){
        return addressRemote.addressList(address);
    }

    @PostMapping(value = "/member/address")
    @ApiOperation(value = "通过id获得收货地址")
    public Result<VOAddress> address(@RequestBody VOAddress address){
        return addressRemote.address(address);
    }

    @PostMapping(value = "/member/address/add")
    @ApiOperation(value = "添加收货地址")
    public Result<Object> addAddress(@RequestBody VOAddress address){
        return addressRemote.addAddress(address);
    }

    @PostMapping(value = "/member/address/update")
    @ApiOperation(value = "编辑收货地址")
    public Result<Object> updateAddress(@RequestBody VOAddress address){
        return addressRemote.updateAddress(address);
    }

    @PostMapping(value = "/member/address/del")
    @ApiOperation(value = "删除收货地址")
    public Result<Object> delAddress(@RequestBody VOAddress address){
        return addressRemote.delAddress(address);
    }
}
